Repository navigation
One Hessian cover per sweep, and cheaper CurvatureScales - #73
Merged
Merged
Conversation
MergeRule and its four rules move unchanged from jacobian.jl into mergerules.jl, which is included before covers.jl, so that every file of the package can name them. Assisted-by: Claude Opus 5.5 <noreply@anthropic.com>
cover_hessian(CoverOnly(), ...) and cover_nls take
`merge = SumMerge()`, the default, or `merge = SignAveragedMerge()`,
and return the selected cover as the field `h`. The rule is the third
type parameter of the result, HessianCover{T, M, R}, NLSCover{T, M, R}
or NLSDiagnostics{T, M, R}, which the keyword makes inferrable; the
results carry no h_sum/h_var or h_var/h_var_gn fields. Any other rule
throws. cover_hessian(WithDiagnostics(), ...) returns the sum cover
and refuses any rule but SumMerge, naming CoverOnly(). SumMerge and
SignAveragedMerge are exported and MergeRule is public.
The CoverOnly sweep carries the adjoint and the one selected channel.
It forms the absolute adjoint only at nodes with second partials, and
tests a node's channel for finiteness once instead of testing every
zero partial. The gradient, the sum cover and nguarded are unchanged
bit for bit; the sign-averaged cover can change in its last bit where
a first partial is exactly zero, which now enters the `hypot` as a
zero term.
With CurvatureScales, the scales still derive from sum covers, so the
sign-averaged cover of a program with guarded blocks adds one sum
sweep of the drop pass.
For least squares, the sign-averaged covers do not depend on
`ngroups`, and cover_nls refuses `ngroups != 1` with them. Under
WithDiagnostics, `check` verifies the sign-averaged h_gn against the
column norms of Utilde.
Assisted-by: Claude Opus 5.5 <noreply@anthropic.com>
With `scales = CurvatureScales()`, the sign-averaged cover now derives its scales from sign-averaged covers: the drop pass and every later round sweep the cover the entry point returns. The sign-averaged cover transforms as the sum cover does, so the scales remain covariant, and the two covers vanish at the same inputs, so the anchored inputs are the same. A program with guarded blocks no longer pays for a sum sweep of the drop pass in addition to its own. The two covers of one program can now split a guarded block differently. The sum cover is unchanged. derived_scales and resolve_scales take the merge rule, and so does local_covers, which passes it to the derivation and refuses a rule no sweep can carry; cover_nls passes its own, so its covers derive their scales from the loss tape's Hessian cover of the same kind. Orderings between the two covers are documented for covers under the same declared scales. Assisted-by: Claude Opus 5.5 <noreply@anthropic.com>
Only the guarded blocks read the declared scales, so under CurvatureScales a round no longer repeats the whole cover sweep. The drop pass records each block it drops (DroppedBlock) with its parents, its node and the slot covers the pass gave that node. Each round, the final one included, splits those nodes alone under the derived scales (guarded_covers) and adds the change to the drop pass's cover in one reverse sweep seeded at their parents (raised_cover). Both covers are linear in their seeds, the sign-averaged cover in their squares, and a split weight is never below the diagonal weight the drop pass gave the same slot, so every change is nonnegative. The forward sweeps of the check of unanchored inputs sum to the first round's propagated scales, which that round reuses. The rounds also reuse the drop pass's live_nodes. A program without guarded blocks still pays only for the empty record. On the local-covers path (cover_nls, cover_hybrid and the other entry points built on local_covers), the recomputed slot covers replace the dropped ones and the seeds are summed in node order as before. Covers through either path agree with a full sweep under the same scales to within rounding. On a tape whose sweeps round upward, such as an interval tape, a slot's seed rises by an upper bound on the difference of its two weights (boundsub): exact where Sterbenz's lemma applies, and one step above the nearest-rounded difference otherwise. Assisted-by: Claude Opus 5.5 <noreply@anthropic.com>
Under CurvatureScales, only the parents of the dropped blocks read the propagated declared scales, so the forward sweeps that form them, in the check of unanchored inputs and in each round, visit only those parents' ancestors (ancestor_cone). abs_forward and sensitivity_scales take the cone. DeclaredScales carries it and throws if a split asks for a scale outside it. GuardedRedo records the dropped blocks' parents with their cone, so derived_scales takes only the CurvatureScales and the GuardedRedo. Assisted-by: Claude Opus 5.5 <noreply@anthropic.com>
timholy
force-pushed
the
teh/merge-select
branch
from
November 14, 2026 16:36
e45b9d6 to
017c64f
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
cover_hessian(CoverOnly(), ...)andcover_nlsnow return one cover per sweep, chosen by amergekeyword:SumMerge()(the default, the certified sum cover) orSignAveragedMerge()(the sign-averaged cover). The result holds it in the fieldh(for least squares,handh_gn) and records the rule as its third type parameter, e.g.HessianCover{T, M, R}. A caller that wants both covers runs two sweeps of about the same cost each.Breaking: the fields
h_sumandh_varofHessianCover, andh_varandh_var_gnofNLSCoverandNLSDiagnostics, are removed.HessianDiagnosticsis unchanged.SumMergeandSignAveragedMergeare now exported andMergeRuleis public. The package version is still 1.0.0.CurvatureScalesalso costs less:Without guarded blocks, the gradient, the sum cover and
nguardedare unchanged bit for bit; the sign-averaged cover can change in its last bit. WithCurvatureScales, the sum cover agrees with a full sweep under the same scales to within rounding, and on interval tapes the change added to the drop pass's cover is rounded upward, so the cover stays certified.Commits, in order:
src/mergerules.jl(no change in behavior).mergekeyword.🤖 Generated with Claude Code